The present invention relates to an arithmetic unit for exponential function utilized in a computer.
Exponential calculation is one of the necessary functions for computers of the type carrying out scientific and technological computation. The calculation methods of exponential function include a method utilizing Taylor series expansion: EQU e.sup.x -1=x+x.sup.2 /2!+x.sup.3 /3!+. . . +x.sup.n /n!. . .(1)
and a method according to meromorphic function approximation using continued fraction expansion or Tchebycheff series expansion. However, these methods have drawbacks that they need a relatively long calculation time due to frequent repetition of multiplication and division and they do not provide a sufficient calculation precision.
Further, there is another calculation method for exponential function of Sequential Table Look-Up (hereinafter, referred to as "STL") which is suitable for micro-program-controlled computer. Since the STL method can be carried out by adding operation, substracting operation and right-shifting operation, this method is efficient for use in computers which have no fast multiplier unit.
Arithmetic principle of the STL method is explained hereinbelow for calculating an exponential function according to binary notation with the precision of n bits. In this method, the input value x is represented by using a constant number .gamma..sub.k and a series {a.sub.k } as follows: EQU x=a.sub.o x.gamma..sub.o +a.sub.1 x.gamma..sub.1 +a.sub.2 x.gamma..sub.2 +. . . +a.sub.n-1 x.gamma..sub.n-1 +.epsilon. (2)
where EQU .gamma..sub.k =loge(1+2.sup.-k) (3) EQU a.sub.k ={+1,0} (4)
Accordingly, the exponential function e.sup.x -1 is represented by the following relation: EQU e.sup.x -1=(1+2.sup.-1).sup.a1 x(1+2.sup.-2).sup.a2. . . x(1+2.sup.-(n-1)).sup.an-1 x(2.sup..epsilon. -1) (5)
In this method, determination of the series {a.sub.k } from the input value x it called pseudo division, and determination of the value of exponential function e.sup.x -1 from the series {a.sub.k } is called pseudo multiplication.
The above-mentioned determinations include the following operation steps for the number sequential k. EQU W= .phi..sub.k -.gamma..sub.k ( 6)
If W.gtoreq.0, EQU a.sub.k =+1 (7) EQU .phi..sub.k+1 =W (8) EQU .epsilon..sub.k+1 =.epsilon..sub.k +2.sup.-k x.epsilon..sub.k( 9) PA1 If W&lt;0 EQU a.sub.k =0 (10) EQU .phi..sub.k+1 =.phi..sub.k ( 11) EQU .epsilon..sub.k+1 =.epsilon.k (12) PA1 1. The initial values x.sub.o =x(1.ltoreq.x&lt;loge2) and y.sub.o =1 are set. PA1 2. The following operation 3 is repeatedly carried out for the number k=0, 1, 2, . . . , n-1. PA1 3. EQU W=x.sub.k -.gamma..sub.k ( 13) PA1 If W.gtoreq.0, EQU a.sub.k =+1 (14) EQU x.sub.k+1 =W (15) EQU y.sub.k+1 =y.sub.k +y.sub.k x2.sup.-k (16) PA1 If W&lt;0, EQU a.sub.k =0 (17) EQU x.sub.k+1 =x.sub.k ( 18) EQU y.sub.k+1 =y.sub.k ( 19) PA1 where the number .gamma..sub.k is a constant value satisfying the relation (3). PA1 4. The value of exponential function e.sup.x -1 is obtained as the value y.sub.n -1. PA1 1. For the initialization, the register 207 is set with the initial value x.sub.o =x (step 301), the register 208 is set with the initial value y.sub.o =1 (step 302), the counter 201 is set with the sequential number k=0 (step 304), and the counter 206 is set with the desired loop cycle number n which corresponds to the bit number of exponential function value to be determined (step 303). PA1 2. The following loop procedure 3 is repeatedly carried out n times according to the decrement of content of the counter 206 from n to 1. PA1 3. Before the k-th loop procedure the register 208 has been stored with the variable y.sub.k determined by the relation (16) or (19), the register 207 has been stored with the variable x.sub.k determined by the relation (15) or (18), the register 205 has been stored with the variable W determined by the relation (13), the counter 201 has been set to the sequential number k and the counter 206 has been set to the number n. PA1 4. The above-described loop procedure is repeated n times until the content of register 206 becomes zero (step 309), and finally the content y.sub.n of the register 208 approaches to y.sub.n =e.sup.x, thereby obtaining the value of e.sup.x -1 by substracting 1 from y.sub.n (step 310). PA1 1. To determine the value of e.sup.x -1, the given value of variable x (0.ltoreq.x&lt;+.infin.) is inputted into the arithmetic unit. PA1 2. The value of x is converted into the floating point representation x=2.sup.-i xX (1.ltoreq.X&lt;2, i:integer number) to determine the complement i and mantissa X and the initial value is set to x.sub.i =X. PA1 3. The pseudo division is carried out by repeating the following step 4 for the sequential number k=i, i+1, i+2, . . . , m-1. PA1 4. EQU W=X.sub.k -.tau..sub.k, where .tau..sub.k =2.sup.k xloge(1+2.sup.-k)(21) PA1 If W.gtoreq.0, EQU a.sub.k =+1 (22) EQU X.sub.k+1 =2xW (23) PA1 If W&lt;0, EQU a.sub.k =0 (24) EQU X.sub.k+1 =2xX.sub.k (25) PA1 5. The initial value Y.sub.m for the pseudo multiplication is set as follows: EQU Y.sub.m =X.sub.m (26) PA1 6. The pseudo multiplication is carried out by reverse sequentially repeating the following step 7 for sequential number k=m, m-1, m-2, . . . , i+1. PA1 7. If a.sub.k =+1, EQU Y.sub.k-1 =(Y.sub.k +2.sup.k xY.sub.k +1)/2 (27) PA1 If a.sub.k =0, EQU Y.sub.k-1 =Y.sub.k /2 (28) PA1 8. The value of exponential function is determined as e.sup.x -1=Y.sub.i.
By repeatedly carrying out these steps, the value of .phi..sub.k approaches to zero to thereby obtain the value of exponential function e.sup.x -1=.epsilon..sub.k -1.
In these operation steps, the relation (6) represents the pseudo division for determining the series {a.sub.k }, and the relations (8), (9), (11) and (12) represent the pseudo multiplication for determining the value of e.sup.x from the series {a.sub.k }.
In these operations, the algorithm of STL method is represented as follows.
The conventional algorithm of STL method is effected by an arithmetic unit shown in FIG. 2 according to the procedure illustrated in flow chart of FIG. 3 Referring to FIG. 2, the arithmetic unit includes a pair of shift registers 207 and 208 which store two kinds of binary variables x.sub.k and y.sub.k, respectively, a barrel shifter 203 which carries out the right shift operation by a given shift bit count, an n-word ROM 202 of n words for
generating the constant number .gamma..sub.k defined by the relation (3), and an adder-subtracter 204 for adding or substracting the content of an input port A and content of an input port B to or from each other. A counter 206 is provided to control loop cycle number, and another counter 201 is provided to designate the shift bit count k in the barrel shifter 203 and to designate the integer number k for addressing the ROM 202.
Next, the operation of arithmetic unit shown in FIG. 2 is explained in conjunction with the algorithm of STL method illustrated in FIG. 3.
During the k-th loop procedure, the barrel shifter 203 operates to right-shift binary data fed from a data bus 209 by a shift bit count k indicated by the counter 201 to thereby multiply the data by 2.sup.-k, and operates to return the multiplied data to the data bus 209. In the step 305, the variable x.sub.k stored in the registor 207 is transferred to the input port A of the adder-subtracter 204, and the constant value .gamma..sub.k stored in the address of ROM 203 designated by the sequential number k set in the counter 201 is transferred to the input port B of the adder-subtracter 204 The adder-subtracter 204 substracts the constant value .gamma..sub.k from the variable x.sub.k to calculate W=x.sub.k -.gamma..sub.k, and the calculated result W is transferred to the register 205.
In the step 306, if the value of sign bit is positive or W&gt;0 in the register 205, the following operation is carried out. Firstly, the content of the register 205, i.e., the fore mentioned calculation result W is transferred to the register 207 (step 311) whereby the update variable x.sub.k is set to W. Next, the variable y.sub.k stored in the register 208 is transferred to the input port A of the adder-subtracter 204. At the same time, the barrel shifter 203 right-shifts the variable y.sub.k by the shift bit count k indicated by the counter 201 to thereby obtain the value y.sub.k x2.sup.-k and transfers the same to the input port B of the adder-subtracter 204 The adder-subtracter 204 adds the values y.sub.k and y.sub.k x2.sup.-k to each other to carry out the calculation y.sub.k +1=y.sub.k +y.sub.k x2.sup.-k. The calculated result is transferred to the register 208 to update its content to y.sub.k+1 =y.sub.k +y.sub.k x2.sup.-k.
On the other hand, in the step 306, if the value of sign bit is negative or W&lt;0, the contents of the registers 207 and 208 are not changed, i.e., x.sub.k+1 =x.sub.k and y.sub.k+1 =y.sub.k, respectively (steps 321 and 322).
Then, the sequential number k of the counter 201 is updated to k+1 (step 307), and the content n of the counter 206 is updated to n-1 (step 308), and procedure returns to the step 305 with the sequential number k+1.
The above procedure has been carried out conventionally by micro program. In such method, if one loop procedure 3 requires .alpha. number of clocks, the whole calculating procedure requires nx.alpha. number of clocks and therefore spends a great amount of calculation time.
The above-described conventional arithmetic unit for exponential function has the following drawbacks. Firstly, the precision of calculation result is not good. Namely, since the constant value .gamma..sub.k defined by the relation (3) becomes small in accordance with the increment of sequential number k, significant figure of the constant value .gamma..sub.k is decreased and the rounding error is accumulated about the least significant bit (LSB). Further, since calculation of the relations (8), (9), (11) and (12) is based on the algorithm with fixed point number, if the variable x and value of the exponential function e.sup.x -1 are represented by floating point number, the variable x has to be converted into the fixed point number to calculate the value of e.sup.x -1 and then the value of e.sup.x -1 of the fixed point number has to be converted into the floating point number. In such case, if the variable x has a very small value, the significant figures are considerably reduced through the conversion into the fixed point number.
Secondly, the conventional method requires a considerably long calculation time. Namely, since the process of STL method (based on the arithmetic relations (6), (8), (9), (11) and (12)) is carried out entirely by micro program, if one loop procedure of the STL method requires .alpha. number of clocks, the whole procedure requires nx.alpha. number of clocks, resulting in a considerably long calculation time.